Picture of Brian Love wearing black against a dark wall in Portland, OR.

Brian Love

Lowercase Your URIs

For SEO purposes, it is often necessary to enforce lowercase URIs on your website. Google (and I believe all other search engines) are case sensitive. In other words, they will recognize the following URLs as two separate and distinct pages:

This is especially problematic if you are using a case insensitive file system such as Windows. Further, as these pages are seen as separate and distinct and contain the same content, you may be penalized for duplicate content. In essence, you are splitting the value of the content between the pages that are distinct, which will water down the SEO value of the page.

The common solution to this problem is to enforce lowercase URIs on your website. We will look at implementing this using Apache’s mod_rewrite module, IIS rewriting (available in IIS 7 and greater), and the ISAPI rewrite extension for IIS.

Apache mod_rewrite Module

First, we need to declare a RewriteMap in our httpd.conf file. The httpd.conf file is commonly located at: /private/etc/apache2/httpd.conf. Add the following lines to the end (or anywhere you prefer) of your httpd.conf file.

# Add RewriteMap for redirecting to lowercase URIs
<IfModule mod_rewrite.c>
RewriteMap lc int:tolower
</IfModule>

Next, create the RewriteRule to redirect uppercase URLs to lowercase ones.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^(.*)$ ${lc:$1} [R=301,L]

Let me explain each line of the code above.

IIS Rewrite

Add the following code to your web.config file located in the root of your web folder.

<rule name="LowerCaseRule" stopProcessing="true">
<match url="[A-Z]" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{URL}}" />
</rule>

Helicon’s ISAPI Rewrite Extension

We actually use both Apache mod_rewrite (for development on OS X) and the ISAPI rewrite extension (for Windows servers). Thankfully there is fairly good cross support between the two. There is one notable difference between Apache’s mod_rewrite module and the ISAPI rewrite extension: for Apache mod_rewrite the RewriteMap must be declared at the server (or virtual host) level, and for ISAPI rewrite it must be declared with the RewriteCond in the .htaccess file for your website.

We simply add the following code to the .htaccess file to redirect all uppercase URI requests to lowercase.

RewriteMap lc int:tolower
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^(.*)$ ${lc:$1} [R=301,L]

In summary, all methods are fairly easy to implement. The only catch is the difference in support for the RewriteMap declaration between Apache’s mod_rewrite module and Helicon’s ISAPI Rewrite extension. I hope this helps with your SEO efforts!